/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package UDP;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;

/**
 *
 * @author Antonio Pedro
 */
public class UDPSender {
     public static void main(String args[]) throws Exception {

        try {

            DatagramSocket socket = new DatagramSocket();
            // Endereço de Broadcast
            InetAddress group = InetAddress.getByName("192.168.1.255");
            
            // Enviando 2 bytes em broadcast
            DatagramPacket packet = new DatagramPacket(new byte[]{1, 1}, 2, group, 2222);
            socket.send(packet);

        } catch (Exception ex) {

            System.out.println("!");
        }
    }
}
